package qf.sail.controller;

import qf.sail.entity.Account;
import qf.sail.service.OrderService;
import qf.sail.service.ShopCarService;
import qf.sail.service.impl.OrderServiceImpl;
import qf.sail.service.impl.ShopCarServiceImpl;
import qf.sail.vo.ResultVO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/addShopCar")
public class AddShopCarServlet extends BaseServlet{
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ShopCarService shopCarService = new ShopCarServiceImpl();
        Account account = (Account) req.getSession().getAttribute("account");
        //生成购物车子项
        long goodId = Long.parseLong(req.getParameter("goodId"));
        int count = Integer.parseInt(req.getParameter("count"));
        String color = req.getParameter("color");
        String size = req.getParameter("size");

        shopCarService.addItemToShopCar(goodId,account.getId(),size,color,count);
        
        ResultVO resultVO = new ResultVO();
        repSuccess(resp,resultVO);

    }
}
